<template>
	<view>
		<view class="tittle">
			账号密码 注册
		</view>
		<view class="account">
			账号
			<input type="text"  placeholder="请输入账号" v-model="account"/>
		</view>
		<view class="account">
			密码
			<input type="password"  placeholder="请输入密码" v-model="password"/>
		</view>
		<view  @click='gologin' class="register" >
			去登录
		</view>
		<view :class="password.length?'btn active':'btn'" @click="register">
			注册
		</view>
	</view>
</template>

<script>
	import util from '../../utils/index.js'
	export default {
		data() {
			return {
				account:'',
				password:''
			}
		},
		methods: {
			register(){
				util.myRequest({
					url:'/register',
					data:{
						account:this.account,
						password:this.password
					}
				}).then(res=>{
					if(res.code==='001'){
						uni.showToast({
							title: '注册成功',
							success(){
								uni.setStorageSync('user',{uuid:res.uuid})
								uni.switchTab({
									url:'../index/index'
								})
							}
						})
					}else{
						uni.showToast({
							title: res.msg,
							icon:'none'
						})
					}
				})
			},
			gologin(){
				uni.navigateTo({
					url:'../login/login'
					})
			}
		}
	}
</script>

<style lang="scss">
.tittle{
	font-size: 50upx;
	margin: 215upx 0 93upx 38upx;
	font-weight: 700;
}
.account{
	border-bottom: 1px solid #CCCCCC;
	width: 680upx;
	margin:  0 auto;
	line-height: 80upx;
	font-size: 32upx;
	input{
		vertical-align: bottom;
		width: 490upx;
		height: 80upx;
		float: right;
	}
}
.register{
	font-size: 28upx;
	color: #395383;
	margin: 58upx 0 115upx 35upx;
}
.btn{
	width: 678upx;
	line-height: 82upx;
	font-size: 30upx;
	color: #fff;
	background-color: #9be7be;
	border-radius: 8upx;
	margin: 0 auto;
	text-align: center;
	&.active{
		background-color:  #2b9939;
	}
}
</style>
